<?php
/**
 * Copyright (c) 2006, PORTALIER Julien
 *
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 *
 * @package      FeatherCMS
 * @subpackage   Licenses
 * @copyright    Copyright (c) 2006, Julien PORTALIER
 * @link         http://julien.portalier.com
 * @license      http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 */

require APP.'config'.DS.'licenses.php';

class LicenseHelper extends Helper
{
	function & getLicenses($default=null)
	{
		$licenses = array();
		
		foreach (Licenses::$licenses as $key => $license)
		{
			#$licenses[$key] = $this->link($license['name'], $license['resource']);
			$licenses[$key] = $license['name'];
		}
		
		if (!empty($default))
			$licenses[''] = $default;
		
		return $licenses;
	}
	
	function getLink($license)
	{
		return $this->link(Licenses::$licenses[$license]['name'], Licenses::$licenses[$license]['resource']);
	}
	
	function getRDF($license, $resource)
	{
		ob_start();
		echo '<rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">';
		echo '<Work rdf:about="'.$resource.'">';
		echo '<license rdf:resource="'.Licenses::$licenses[$license]['resource'].'" />';
		echo '</Work>';
		
		$rdf = APP.'config'.DS.'licenses'.DS.str_replace('/', '_', $license).'.rdf';
		if (file_exists($rdf))
		{
			echo '<License rdf:about="'.Licenses::$licenses[$license]['resource'].'">';
			echo file_get_contents($rdf);
			echo '</License>';
		}
		echo '</rdf:RDF>';
		return ob_get_clean();
	}
}
?>